package com.dcits.account.entity.cto;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 2843896844@qq.com
 * @Date: 2021/06/11/13:35
 * @Description:
 */
public class OutputObject/*<T>*/ implements Serializable {

    public static final String SUCCESS_CODE = "0";

    public static final String FAILED_CODE = "-9999";

    private String rtnMsg;

    private String rtnCode;

    private List<Object> beans = new ArrayList<Object>();

    private bean bean = new bean();

    //private T data;

    public OutputObject() {
    }

    public String getRtnMsg() {
        return rtnMsg;
    }

    public void setRtnMsg(String rtnMsg) {
        this.rtnMsg = rtnMsg;
    }

    public String getRtnCode() {
        return rtnCode;
    }

    public void setRtnCode(String rtnCode) {
        this.rtnCode = rtnCode;
    }

    public List<Object> getBeans() {
        return beans;
    }

    public OutputObject.bean getBean() {
        return bean;
    }

//    public T getData() {
//        return data;
//    }
//
//    public void setData(T data) {
//        this.data = data;
//    }

    @Override
    public String toString() {
        return "OutputObject{" +
                "rtnMsg='" + rtnMsg + '\'' +
                ", rtnCode='" + rtnCode + '\'' +
                ", beans=" + beans +
                ", bean=" + bean +
                '}';
    }

    public static OutputObject success() {
        OutputObject outputObject = new OutputObject();
        outputObject.setRtnCode(SUCCESS_CODE);
        outputObject.setRtnMsg("success");
        return outputObject;
    }

    public static OutputObject success(String rtnMsg) {
        OutputObject outputObject = new OutputObject();
        outputObject.setRtnCode(SUCCESS_CODE);
        outputObject.setRtnMsg(rtnMsg);
        return outputObject;
    }

    public static OutputObject failed(String rtnMsg) {
        OutputObject outputObject = new OutputObject();
        outputObject.setRtnCode(FAILED_CODE);
        outputObject.setRtnMsg(rtnMsg);
        return outputObject;
    }

    public static OutputObject failed() {
        OutputObject outputObject = new OutputObject();
        outputObject.setRtnCode(FAILED_CODE);
        outputObject.setRtnMsg("failed...");
        return outputObject;
    }

    public OutputObject failedWithMsg(String rtnMsg) {
        this.setRtnCode(FAILED_CODE);
        this.setRtnMsg(rtnMsg);
        return this;
    }

    public Boolean isFailed(){
        return this.rtnCode.equals(FAILED_CODE);
    }

    public String toJSONString() {
        return JSON.toJSONString(this);
    }

    public class bean extends HashMap {
    }
}
